package test
{
	import _Pan3D.display3D.Display3DContainer;
	import _Pan3D.display3D.Display3DMovie;
	import _Pan3D.display3D.Display3DShadowSprite;
	import _Pan3D.display3D.Display3DSprite;
	import _Pan3D.program.Program3DManager;
	import _Pan3D.program.shaders.Md5Shader;
	import _Pan3D.program.shaders.ShadowShader;
	import _Pan3D.program.shaders.StatShader;
	import _Pan3D.texture.TextureManager;
	
	import _me.KeyControl;
	import _Pan3D.core.MathCore;
	import _me.Scene_data;
	
	import com.adobe.utils.PerspectiveMatrix3D;
	
	import flash.display3D.Context3D;
	import flash.display3D.Context3DProgramType;
	import flash.display3D.Program3D;
	import flash.events.Event;
	import flash.geom.Vector3D;

	[SWF(backgroundColor="#FFFFFF",width="1024", height="600", frameRate="60")]
	public class loadObj extends BaseDemo
	{
		private var _programMd5:Program3D;
		private var _guaiwu:Display3DMovie;
		private var wow:Display3DContainer;
		private var statShaderProgram3d:Program3D;
		private var mc_box512:Display3DSprite;
	
		public function loadObj()
		{
			super();
		}
		override protected function makeScene():void
		{
			Scene_data._sunMatrix.identity();
			Scene_data._sunMatrix.prependTranslation(0, 0, -4000);
			Scene_data._sunMatrix.prependRotation(120, new Vector3D(1, 0, 0));
			Scene_data._sunMatrix.prependTranslation(0, 0, 0);
			
			var context : Context3D = Scene_data.context3D;
			TextureManager.getInstance().init(context);
			container=new Display3DContainer;
		
			statShaderProgram3d = Program3DManager.getInstance().getProgram(StatShader.STATSHADER);
			wow = new Display3DContainer();


			var sp1:Display3DSprite = new Display3DSprite(context);
			sp1.url = "baseGround";
			wow.addChild(sp1);
			mc_box512 = new Display3DSprite(context);
			mc_box512.url = "box512";
			mc_box512.rotationY=45
			wow.addChild(mc_box512);
			var sp3:Display3DSprite = new Display3DSprite(context);
			sp3.url = "yanzhu";
			sp3.y=0
			sp3.z=-100

			wow.addChild(sp3);
			wow.setProgram3D(statShaderProgram3d);
			container.addChild(wow);
			this.addEventListener(Event.ENTER_FRAME, enterFrame);
			Scene_data.cam3D.distance = 300;
			Scene_data.focus3D.angle_y = 0;
			Scene_data.focus3D.angle_x =-30;
		}
		override protected function  enterFrame(event : Event) : void {
			keyControl.upData();
			MathCore._catch_cam(Scene_data.cam3D, Scene_data.focus3D);
			Scene_data.cam3D.toString();
			if (!Scene_data.ready ) return;
			var context : Context3D = Scene_data.context3D;
			context.clear(0, 0, 0, 1);
			projMatrix = new PerspectiveMatrix3D();
			projMatrix.perspectiveFieldOfViewRH(1, 1, 0.1, 90000);
			context.setProgramConstantsFromMatrix(Context3DProgramType.VERTEX, 0, projMatrix, true);
			container.update();
			context.present();

		}
	}
}